<?php
#最新的定位信息
class NewLocationModel extends PdoModel {
    protected $_name = 'new_location';

    function __construct(){
        parent::__construct();
    }

    #添加
    function addData($data){
        if(empty($data)){
            return false;
        }
        return $this->insert($data);
    }

    #删除
    function deleteData($id = 0){
        if(empty($id)){
            return false;
        }
        $row = $this->find("id = {$id}");
        if (empty($row)) {
            return false;
        }
        return $this->delete("id = {$id}");
    }

    #更新
    function updateDataByUid($data,$uid){
        return $this->update($data,"uid = {$uid}");
    }

    #更具UID查找信息
    function getDataByUid($uid){
        if(empty($uid)){
            return array();
        }

        $sql = " select * from {$this->_name} where uid={$uid} limit 1";
        $result = $this->fetchRow($sql);

        return $result;
    }


    #查询多个用户的最新地理位置
    function getDataByUids($uids){
        if(empty($uids)){
            return array();
        }

        $uids = trim(implode(',', $uids), ',');
        $sql = " select * from {$this->_name} where uid  in({$uids})";
        $result = $this->fetchAll($sql);

        return $result;
    }


}
